home *** CD-ROM | disk | FTP | other *** search
- // Dynamic link library implementation of NeuroSolutions FullSynapse component
-
- #include "NSDLL.h"
-
- /*************************************************************/
- /* Macros to access the PE layers and weights in matrix form */
-
- #define in(i,j) input[j+i*inCols]
- #define out(i,j) output[j+i*outCols]
- #define W(i,j) weights[j+i*inCount]
-
- /***********************************/
- /* Forward activation of component */
-
- __declspec(dllexport) void performFullSynapse(
- DLLData *instance, // Pointer to instance data (may be NULL)
- NSFloat *input, // Pointer to the input layer of processing elements (PEs)
- int inRows, // Number of rows of PEs in the input layer
- int inCols, // Number of columns of PEs in the input layer
- NSFloat *output, // Pointer to the output layer
- int outRows, // Number of rows of PEs in the output layer
- int outCols, // Number of columns of PEs in the output layer
- NSFloat *weights // Pointer to the fully connected matrix of weights
- )
- {
- int i, j,
- inCount=inRows*inCols,
- outCount=outRows*outCols;
-
- for (i=0; i<outCount; i++)
- for (j=0; j<inCount; j++)
- output[i] += W(i,j)*input[j];
- }
-
- /******************************************/
- /* Management of instance data (OPTIONAL) */
- /*
- __declspec(dllexport) DLLData *allocFullSynapse(
- DLLData *oldInstance, // Pointer to the last instance if reallocating
- int inRows, // Number of rows of PEs in the input layer
- int inCols, // Number of columns of PEs in the input layer
- int outRows, // Number of rows of PEs in the output layer
- int outCols // Number of columns of PEs in the output layer
- )
- {
- DLLData *instance = allocDLLInstance(oldInstance);
- return instance;
- }
-
- __declspec(dllexport) void freeFullSynapse(DLLData *instance)
- {
- freeDLLInstance(instance);
- }
- */